<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Email extends CI_Controller {
	public function index()
	{	
		echo "<h1>email page<h1>
			<table>
			<form action='/email/send' method='post'>
				<tr>
					<td><lable>To</lable></td>
					<td><input name='to'/></td>
				</tr>
				<tr>
					<td><lable>subject</lable></td>
					<td><input name='subject'/></td>
				</tr>
				<tr>
					<td><lable>message</lable></td>
					<td><input name='message'/></td>
				</tr>
				<tr>
					<input type='submit' value='Send'/>
				</tr>
			</form>
			</table>
			";
	}
	public function send(){
// 		var_export($_POST);
		$this->load->library('email');
		
		$config['smtp_user'] = 'color3dp@163.com';
		$config['smtp_pass'] = 'Cmail@qq.com';
		$config['smtp_host'] = 'smtp.163.com';
		$config['protocol'] = 'smtp';
		$config['mailpath'] = 'news/index';
// 		$config['charset'] = 'iso-8859-1';
// 		$config['charset'] = 'gb2312';
		$config['wordwrap'] = TRUE;
		
		$this->email->initialize($config);
		
		
		$this->email->from('color3dp@163.com', 'Stony');
		$this->email->to('color3dp@126.com');
		$this->email->cc('color3dp@126.com');
		$this->email->bcc('color3dp@126.com');
		
		$this->email->subject('codeIgniter Email Test');
		$this->email->message('Testing the email class.');
// 		$this->email->attach('D:/QCallServer/htdocs/CI/public/images/google.jpg');
		$this->email->send();
		
		echo $this->email->print_debugger();
	}
}
